/**
 * Created by Administrator on 2016/7/20.
 */
angular.module('app.controllers', [])

    .controller("LoginCtrl", function($scope, AdminManager,$window){
        $scope.data = {};
        $scope.btnClickLogin = function(){
            AdminManager.administratorLoginBackground($scope);
        };

        //回车实现登录功能
        $scope.enterEvent = function(e) {
            var keycode = window.event?e.keyCode:e.which;
            if(keycode==13){
                AdminManager.administratorLoginBackground($scope);
            }
        };

        $scope.setStyle = {
            "height" : $window.innerHeight
        }

    })

    .controller("UserManagerCtrl", function($scope, Data, CollegeManager, User){
        $scope.nowUrl = '#/usermanager';
        $scope.data={};
        $scope.data.operationList = Data.operationList;
        CollegeManager.getProvinceList($scope);
        // $scope.provinceChange = function (provinceID) {
        //     $scope.provinceID = provinceID;
        //     CollegeManager.getCityList($scope, provinceID);
        // };
        // $scope.cityChange = function(cityID){
        //     $scope.cityID = cityID;
        //     CollegeManager.getCollegeList($scope, cityID);
        // };
        // $scope.collegeChange = function(collegeID){
        //     $scope.collegeID = collegeID;
        // };

        // User.getUserListBriefBackground($scope,'');
        // User.getUserAmountBackground($scope);
        $scope.data.number = parseInt(localStorage.userPageNum);
        var num = 10;
        var startIndex = localStorage.userPageNum * num - num;
        if($scope.data.search == undefined){
            $scope.data.search = '';
        }
        $scope.data.prevDisable = true;
        $scope.data.nextDisable = false;

        $scope.nextPageBtn = function(){
            startIndex= startIndex + num;
            User.getUserPagelist($scope,$scope.data.search,startIndex);
            $scope.data.number = startIndex/num +1;
            console.log("nextstartIndex",startIndex);
            $scope.data.prevDisable = false;
            localStorage.userPageNum = $scope.data.number;
        };
        $scope.prevPageBtn = function(){
            startIndex= startIndex - num;
            User.getUserPagelist($scope,$scope.data.search,startIndex);
            $scope.data.number = startIndex/num +1;
            console.log("onstartIndex",startIndex);
            if($scope.data.number == 1){
                $scope.data.prevDisable = true;
            }
            $scope.data.nextDisable = false;
            localStorage.userPageNum = $scope.data.number;
        };

        $scope.btnClicked = function(){
            if($scope.data.number <= 0 || $scope.data.number==undefined){
                $scope.data.number = 1;
            }
            startIndex = $scope.data.number * num -num;
            User.getUserPagelist($scope,$scope.data.search,startIndex);
            console.log("跳转到第几页",startIndex, $scope.data.number);
            if($scope.data.number == 1){
                $scope.data.prevDisable = true;
            }
            localStorage.userPageNum = $scope.data.number;
        };
        // $scope.deleteBtn = function(){
        //     User.deleteUsersBackground($scope);//出错
        //     startIndex = 0;
        //     $scope.data.number = 1;
        //
        // };

        $scope.searchBtn = function () {
            User.getUserListBriefBackground($scope,$scope.data.search);
            console.log("搜索的是",$scope.data.search);
        };

        User.getUserListBackground($scope, startIndex);
    })

    //招标控制器部分
    .controller("TenderListCtrl", function($scope, Data, TenderManager, DateTimeManager, CollegeManager, $state){
        $scope.data = {};
        $scope.data.operationList = Data.operationList;
        //input日期
        $scope.dtstart = new Date();
        $scope.dtend = new Date();
        DateTimeManager.initDate($scope, $scope.dtstart);
        DateTimeManager.initDate($scope, $scope.dtend);

        var startDatetime = new Date();
        var endDatetime = new Date();
        startDatetime.setYear($scope.dtstart.getFullYear());
        startDatetime.setMonth($scope.dtstart.getMonth());
        startDatetime.setDate($scope.dtstart.getDate());
        $scope.data.startDate = startDatetime.Format("yyyy-MM-dd hh:mm:ss").toString();

        endDatetime.setYear($scope.dtend.getFullYear());
        endDatetime.setMonth($scope.dtend.getMonth());
        endDatetime.setDate($scope.dtend.getDate());
        $scope.data.endDate = endDatetime.Format("yyyy-MM-dd hh:mm:ss").toString();

        $scope.dateTime1 = function(){
            TenderManager.getTenderListBackground($scope, startIndex, $scope.data.startDate, $scope.data.endDate);
            console.log("我失去焦点了");
        };

        $scope.dateTime2 = function(){
            TenderManager.getTenderListBackground($scope, startIndex, $scope.data.startDate, $scope.data.endDate);
            console.log("我也失去焦点了");
        };

        $scope.nowUrl = '#/tenderlist';


        $scope.data.number = parseInt(localStorage.tenderPageNum);

        var num = 10;
        var startIndex = localStorage.tenderPageNum * num - num;
        $scope.number = startIndex;
        $scope.data.cityID = '-1';

        $scope.data.prevDisable = true;
        $scope.data.nextDisable = false;

        $scope.nextPageBtn = function(){
            startIndex= startIndex + num;
            TenderManager.getTenderListBackground($scope, startIndex, $scope.data.startDate, $scope.data.endDate);
            $scope.data.number = startIndex/num + 1;
            console.log("nextstartIndex", startIndex);
            $scope.data.prevDisable = false;
            $scope.number = startIndex;
            localStorage.tenderPageNum = $scope.data.number;
        };
        $scope.prevPageBtn = function(){
            startIndex= startIndex - num;
            TenderManager.getTenderListBackground($scope, startIndex, $scope.data.startDate, $scope.data.endDate);
            $scope.data.number = startIndex/num +1;
            console.log("onstartIndex", startIndex);
            if($scope.data.number == 1){
                $scope.data.prevDisable = true;
            }
            $scope.data.nextDisable = false;
            $scope.number = startIndex;
            localStorage.tenderPageNum = $scope.data.number;
        };

        $scope.btnClicked = function(){
            if($scope.data.number <= 0 || $scope.data.number==undefined){
                $scope.data.number = 1;
            }
            startIndex = $scope.data.number * num -num;
            TenderManager.getTenderListBackground($scope, startIndex, $scope.data.startDate, $scope.data.endDate);
            console.log("跳转到第几页",startIndex, $scope.data.number);
            if($scope.data.number == 1){
                $scope.data.prevDisable = true;
            }
            $scope.number = startIndex;
            localStorage.tenderPageNum = $scope.data.number;
        };

        TenderManager.getTenderListBackground($scope, startIndex); //获取招标详情列表

        CollegeManager.getCityListBackground($scope);  //获取城市列表

        //城市筛选
        $scope.cityChange = function(cityID){
            $scope.data.cityID = cityID;
            startIndex = 0;
            $scope.number = startIndex;
            num = 10;
                $scope.data.number = 1;
            if($scope.data.number == 1){
                $scope.data.prevDisable = true;
            }
            TenderManager.getTenderListBackground($scope, startIndex, $scope.data.startDate, $scope.data.endDate);
        };

        //input框搜索
        $scope.searchBtn = function(){
            TenderManager.getTenderListBackground($scope, startIndex, $scope.data.startDate, $scope.data.endDate);
        };

    })

    //招标详情控制器部分
    .controller("TenderDetailCtrl", function($scope, TenderManager, $stateParams){
        TenderManager.getTenderDetailBackground($scope, $stateParams.tenderID);
    })

    //中标控制器部分
    .controller("WinbiddingListCtrl", function($scope, Data, DateTimeManager, CollegeManager, WinbiddingManager){
        $scope.data = {};
        $scope.data.operationList = Data.operationList;
        $scope.nowUrl = '#/winbiddinglist';
        //input日期框
        $scope.dtstart = new Date();
        $scope.dtend = new Date();
        DateTimeManager.initDate($scope, $scope.dtstart);
        DateTimeManager.initDate($scope, $scope.dtend);

        var startDatetime = new Date();
        var endDatetime = new Date();

        startDatetime.setYear($scope.dtstart.getFullYear());
        startDatetime.setMonth($scope.dtstart.getMonth());
        startDatetime.setDate($scope.dtstart.getDate());
        $scope.data.startDate = startDatetime.Format("yyyy-MM-dd hh:mm:ss").toString()

        endDatetime.setYear($scope.dtend.getFullYear());
        endDatetime.setMonth($scope.dtend.getMonth());
        endDatetime.setDate($scope.dtend.getDate());
        $scope.data.endDate = endDatetime.Format("yyyy-MM-dd hh:mm:ss").toString();

        $scope.dateTime1 = function(){
            WinbiddingManager.getBiddingListBackground($scope, startIndex, $scope.data.startDate, $scope.data.endDate);
            console.log("我失去焦点了");
        };

        $scope.dateTime2 = function(){
            WinbiddingManager.getBiddingListBackground($scope, startIndex, $scope.data.startDate, $scope.data.endDate);
            console.log("我也失去焦点了");
        };

        $scope.data.cityID = '-1';
        $scope.data.number = parseInt(localStorage.biddingPageNum);

        //搜索框
        $scope.searchBtn = function(){
            console.log("获取搜索框的值",$scope.data.search);
            WinbiddingManager.getBiddingListBackground($scope, startIndex, $scope.data.startDate, $scope.data.endDate);
        }
        //input日期

        CollegeManager.getCityListBackground($scope);  //获取招标城市列表

        // 城市筛选
        $scope.cityChange = function(cityID){
            $scope.data.cityID = cityID;
            // console.log("中标cityID:", $scope.data.cityID);
            startIndex = 0;
            $scope.number = startIndex;
            num = 10;
            $scope.data.number = 1;
            if($scope.data.number == 1){
                $scope.data.prevDisable = true;
            }
            WinbiddingManager.getBiddingListBackground($scope, startIndex, $scope.data.startDate, $scope.data.endDate);
        }

        /*********分页*********/
        var num = 10;
        var startIndex = localStorage.biddingPageNum * num - num;
        $scope.number = startIndex;
        $scope.data.cityID = '-1';

        $scope.data.prevDisable = true;
        $scope.data.nextDisable = false;

        $scope.nextPageBtn = function(){
            startIndex = startIndex + num;
            WinbiddingManager.getBiddingListBackground($scope, startIndex, $scope.data.startDate, $scope.data.endDate);
            $scope.data.number = startIndex/num +1;
            $scope.data.prevDisable = false;
            $scope.number = startIndex;
            localStorage.biddingPageNum = $scope.data.number;
        };
        $scope.prevPageBtn = function(){
            startIndex = startIndex - num;
            WinbiddingManager.getBiddingListBackground($scope, startIndex, $scope.data.startDate, $scope.data.endDate);
            $scope.data.number = startIndex/num +1;
            if($scope.data.number == 1){
                $scope.data.prevDisable = true;
            }
            $scope.data.nextDisable = false;
            $scope.number = startIndex;
            localStorage.biddingPageNum = $scope.data.number;
        };
        $scope.btnClicked = function(){
            if($scope.data.number <= 0 || $scope.data.number == undefined){
                $scope.data.number = 1;
            }
            startIndex = $scope.data.number * num - num;
            WinbiddingManager.getBiddingListBackground($scope, startIndex, $scope.data.startDate, $scope.data.endDate);
            console.log("跳转到第几页",startIndex, $scope.data.number);
            if($scope.data.number == 1){
                $scope.data.prevDisable = true;
            }
            $scope.number = startIndex;
            localStorage.biddingPageNum = $scope.data.number;
        };

        WinbiddingManager.getBiddingListBackground($scope, startIndex); //获取中标详情列表

    })

    //中标详情控制器部分
    .controller("WinbiddingDetailCtrl", function($scope, WinbiddingManager, $stateParams){
        WinbiddingManager.getBiddingDetailBackground($scope, $stateParams.biddingID);
    })

    //招标资讯控制器部分
    .controller("TenderNewsCtrl", function($scope, Data, $state, NewsManager){
        $scope.nowUrl = '#/tendernews';
        $scope.data = {};
        $scope.data.operationList = Data.operationList;
        var num = 2;
        var startIndex = localStorage.tenderNewsPageNum * num - num;
        $scope.number = startIndex;
        $scope.data.prevDisable = true;
        $scope.data.nextDisable = false;
        $scope.data.number = parseInt(localStorage.tenderNewsPageNum);

        $scope.nextPageBtn = function(){
            startIndex = startIndex + num;
            NewsManager.getNewsListBackground($scope,startIndex);
            $scope.data.number = startIndex/num +1;
            $scope.data.prevDisable = false;
            $scope.number = startIndex;
            localStorage.tenderNewsPageNum = $scope.data.number;
        };
        $scope.prevPageBtn = function(){
            startIndex = startIndex - num;
            NewsManager.getNewsListBackground($scope,startIndex);
            $scope.data.number = startIndex/num +1;
            if($scope.data.number == 1){
                $scope.data.prevDisable = true;
            }
            $scope.data.nextDisable = false;
            $scope.number = startIndex;
            localStorage.tenderNewsPageNum = $scope.data.number;
        };
        $scope.btnClicked = function(){

            $scope.data.prevDisable = true;
            $scope.data.nextDisable = true;
            if($scope.data.number > Math.ceil($scope.data.count/num)){
                var number = Math.ceil($scope.data.count/num);
                alert('本频道最多' + number + '页');
                return;
            };
            if($scope.data.number <= 0 || $scope.data.number == undefined){
                $scope.data.number = 1;
            }
            startIndex = $scope.data.number * num - num;
            NewsManager.getNewsListBackground($scope,startIndex);
            if($scope.data.number == 1){
                $scope.data.prevDisable = true;
            }
            $scope.number = startIndex;
            localStorage.tenderNewsPageNum = $scope.data.number;
        };

        $scope.createNews = function () {

            $state.go('createnews');
        };

        $scope.deleteTenderNews = function (newsID) {

            console.log('adad',newsID);
            NewsManager.deleteNewsBackground($scope,newsID);
        };

        NewsManager.getNewsListBackground($scope,startIndex);


    })

    //创建招标资讯控制器部分
    .controller("CreateNewsCtrl", function($scope, Data, $state, NewsManager){
        $scope.nowUrl = '#/tendernews';
        $scope.data = {};
        $scope.data.operationList = Data.operationList;
        $scope.btnCreateNews = function () {

            if($scope.data.title == undefined || $scope.data.title == ''){
                alert('请填写标题');
                return;
            }else if($scope.data.content == undefined || $scope.data.content == ''){
                alert('请填写内容');
                return;
            }else{
                // $scope.submit = true;
                NewsManager.createNews($scope);
            }
        }
    })


    //招标资讯详情控制器部分
    .controller("TenderNewsDetailCtrl", function($scope, Data, $state, NewsManager, $stateParams){

        var newsID = $stateParams.newsID;
        NewsManager.getNewsDetailBackground($scope, newsID);

    })


    //企业数据库控制器部分
    .controller("CompanysCtrl", function($scope, Data, CollegeManager, CompanyManager){
        $scope.nowUrl = '#/companys';
        $scope.data = {};
        $scope.data.operationList = Data.operationList;
        $scope.data.cityID = '-1';
        $scope.data.number = parseInt(localStorage.companysPageNum);

        var num = 10;
        var startIndex = localStorage.companysPageNum * num - num;
        $scope.number = startIndex;

        $scope.data.prevDisable = true;
        $scope.data.nextDisable = false;


        $scope.nextPageBtn = function(){
            startIndex = startIndex + num;
            CompanyManager.getCompanyListBackground($scope, startIndex);
            $scope.data.number = startIndex/num +1;
            $scope.data.prevDisable = false;
            $scope.number = startIndex;
            localStorage.companysPageNum = $scope.data.number;
            console.log("$scope.number.next", $scope.number);
        };

        $scope.prevPageBtn = function(){
            startIndex= startIndex - num;
            CompanyManager.getCompanyListBackground($scope, startIndex);
            $scope.data.number = startIndex/num +1;
            if($scope.data.number == 1){
                $scope.data.prevDisable = true;
            }
            $scope.data.nextDisable = false;
            $scope.number = startIndex;
            localStorage.companysPageNum = $scope.data.number;
            console.log("$scope.number.prev", $scope.number);
        };

        $scope.btnClicked = function(){
            if($scope.data.number <= 0 || $scope.data.number==undefined){
                $scope.data.number = 1;
            }
            startIndex = $scope.data.number * num - num;
            CompanyManager.getCompanyListBackground($scope, startIndex);
            console.log("跳转到第几页",startIndex, $scope.data.number);
            if($scope.data.number == 1){
                $scope.data.prevDisable = true;
            }
            $scope.number = startIndex;
            localStorage.companysPageNum = $scope.data.number;
            console.log("$scope.number.next", $scope.number);
        };

        CollegeManager.getCityListBackground($scope);  //获取城市列表
        $scope.cityChange = function(cityID){
            $scope.data.cityID = cityID;
            // console.log("获取的cityID:",$scope.data.cityID);
            startIndex = 0;
            $scope.number = startIndex;
            num = 10;
            $scope.data.number = 1;
            if($scope.data.number == 1){
                $scope.data.prevDisable = true;
            }
            CompanyManager.getCompanyListBackground($scope, startIndex);
        };

        CompanyManager.getCompanyListBackground($scope, startIndex); //获取企业数据库列表


        CompanyManager.getGrade1ListBackground($scope);

        $scope.domClick1 = function($index, gradeID){
            $scope.data.index = $index;
            localStorage.gradeID1 = gradeID;
            CompanyManager.getGrade2ListBackground($scope);
            console.log("dangqiande", $index, gradeID);
        };

        $scope.domClick2 = function($index, gradeID){
            localStorage.gradeID2 = gradeID;
            CompanyManager.getGrade3ListBackground($scope);
            angular.element(".parentDom > li > ul > li").eq($index).children('ul').toggleClass("active");
            console.log("点击了", $index, gradeID);
        };

        $scope.domClick3 = function($index, gradeID){
            localStorage.gradeID3 = gradeID;
            angular.element(".parentDom > li > ul > li").eq($index).children('ul').toggleClass("active");
            console.log("点击了", $index, gradeID);
        };

    })

    //企业数据库详情控制器部分
    .controller("CompanysDetailCtrl", function($scope, CompanyManager, $stateParams){
        $scope.data = {};
        $scope.data.prevDisable = true;
        $scope.data.nextDisable = false;
        $scope.data.achievePrevDisable = true;
        $scope.data.achieveNextDisable = false;
        $scope.data.selfAchievePrevDisable = true;
        $scope.data.selfAchieveNextDisable = false;
        $scope.data.conductPrevDisable = true;
        $scope.data.conductNextDisable = false;
        $scope.data.companyID = $stateParams.companyID;
        var startIndex = 0;
        var startIndex_achieve = 0;
        var startIndex_selfAchieve = 0;
        var num = 10;
        $scope.companydetail = {};
        CompanyManager.getCompanyDetailBackground($scope, $stateParams.companyID);
        CompanyManager.getProjectManagerListBackground($scope, $stateParams.companyID, startIndex);
        CompanyManager.getDelinquenentConductListBackground($scope, $stateParams.companyID, startIndex);
        CompanyManager.getCompanyAchievementListBackground($scope, $stateParams.companyID, startIndex_achieve, 0);
        CompanyManager.getCompanyAchievementListBackground($scope, $stateParams.companyID, startIndex_selfAchieve, 1);

        // console.log("startIndex_selfAchieve", startIndex_selfAchieve, $stateParams.companyID);

        $(".tabs li").click(function(){
            $(this).addClass("active").siblings("li").removeClass("active");
            $(".tabs-child > div").eq($(this).index()).addClass("active").siblings("div").removeClass("active");
        });

        $(".tabs-next li").click(function(){
            $(this).addClass("active").siblings("li").removeClass("active");
            $(".performance > div").eq($(this).index()).addClass("active").siblings("div").removeClass("active");
        });

        $scope.btnSearchManager = function(){
            $(".manager").css({"display" : "block"});
        };

        $scope.btnSearchProject = function(){
            $(".project").css({"display" : "block"});
        };

        $scope.nextPageBtn = function(){
            startIndex = startIndex + num;
            CompanyManager.getProjectManagerListBackground($scope, $stateParams.companyID, startIndex);
            $scope.data.prevDisable = false;
            $scope.number = startIndex;

        };

        $scope.prevPageBtn = function(){
            startIndex = startIndex - num;
            CompanyManager.getProjectManagerListBackground($scope, $stateParams.companyID, startIndex);
            if(startIndex == 0){
                $scope.data.prevDisable = true;
            }
            $scope.data.nextDisable = false;
            $scope.number = startIndex;
        };

        $scope.achieveNextPageBtn = function(){
            $scope.data.achieveNextDisable = true;
            startIndex_achieve = startIndex_achieve + num;
            $scope.data.achieveNumber = startIndex_achieve/num + 1;
            CompanyManager.getCompanyAchievementListBackground($scope, $stateParams.companyID, startIndex_achieve, 0);
            $scope.data.achievePrevDisable = false;
            $scope.achieveNumber = startIndex_achieve;
        };

        $scope.achievePrevPageBtn = function(){
            startIndex_achieve = startIndex_achieve - num;
            $scope.data.achieveNumber = startIndex_achieve/num + 1;
            CompanyManager.getCompanyAchievementListBackground($scope, $stateParams.companyID, startIndex_achieve, 0);
            if(startIndex == 0){
                $scope.data.achievePrevDisable = true;
            }
            $scope.data.achieveNextDisable = false;
            $scope.achieveNumber = startIndex_achieve;
        };

        $scope.selfAchieveNextPageBtn = function(){
            $scope.data.selfAchieveNextDisable = true;
            startIndex_selfAchieve = startIndex_selfAchieve + num;
            $scope.data.selfAchieveNumber = startIndex_selfAchieve/num + 1;
            CompanyManager.getCompanyAchievementListBackground($scope, $stateParams.companyID, startIndex_selfAchieve, 1);
            $scope.data.selfAchievePrevDisable = false;
            $scope.selfAchieveNumber = startIndex_selfAchieve;
        };

        $scope.selfAchievePrevPageBtn = function(){
            startIndex_selfAchieve = startIndex_selfAchieve - num;
            $scope.data.selfAchieveNumber = startIndex/num + 1;
            CompanyManager.getCompanyAchievementListBackground($scope, $stateParams.companyID, startIndex_selfAchieve, 1);
            if(startIndex == 0){
                $scope.selfAchievePrevDisable = true;
            }
            $scope.data.selfAchieveNextDisable = false;
            $scope.selfAchieveNumber = startIndex_selfAchieve;
        };

        $scope.conductNextPageBtn = function(){
            $scope.data.conductNextDisable = true;
            startIndex_selfAchieve = startIndex_selfAchieve + num;
            $scope.data.conductNumber = startIndex_selfAchieve/num + 1;
            CompanyManager.getCompanyAchievementListBackground($scope, $stateParams.companyID, startIndex_selfAchieve, 1);
            $scope.data.conductPrevDisable = false;
            $scope.conductNumber = startIndex_selfAchieve;
        };

        $scope.conductPrevPageBtn = function(){
            startIndex_selfAchieve = startIndex_selfAchieve - num;
            $scope.data.conductNumber = startIndex_selfAchieve/num + 1;
            CompanyManager.getCompanyAchievementListBackground($scope, $stateParams.companyID, startIndex_selfAchieve, 1);
            if(startIndex == 0){
                $scope.conductPrevDisable = true;
            }
            $scope.data.conductNextDisable = false;
            $scope.conductNumber = startIndex_selfAchieve;
        };

    })

    .controller("companyImgCtrl", function($scope, CompanyManager, $stateParams){
        $scope.data = {};
        var startIndex = 0;
        $scope.data.companyID = $stateParams.companyID;
        $scope.data.tag = $stateParams.tag;
        tag = parseInt($stateParams.tag);
        CompanyManager.getCompanyImgBackground($scope, startIndex);

        $scope.data.number = 1;

        var num = 1;

        $scope.data.prevDisable = true;
        $scope.data.nextDisable = false;

        $scope.nextPageBtn = function(){
            $scope.data.nextDisable = true;
            startIndex = startIndex + num;
            CompanyManager.getCompanyImgBackground($scope, startIndex);
            $scope.data.number = startIndex + 1;
            console.log("nextstartIndex",startIndex);
            $scope.data.prevDisable = false;
            console.log("num:", num, startIndex);
        };

        $scope.prevPageBtn = function(){
            startIndex= startIndex - num;
            CompanyManager.getCompanyImgBackground($scope, startIndex);
            $scope.data.number = startIndex + num;
            if($scope.data.number == 1){
                $scope.data.prevDisable = true;
            }
            $scope.data.nextDisable = false;
        };

        $scope.btnClicked = function(){
            if($scope.data.number <= 0 || $scope.data.number==undefined){
                $scope.data.number = 1;
            }
            startIndex = $scope.data.number - 1;
            CompanyManager.getCompanyImgBackground($scope, startIndex);
            console.log("跳转到第几页",startIndex, $scope.data.number);
            if($scope.data.number == 1){
                $scope.data.prevDisable = true;
            }
        };
    })

    //投标数据库控制器部分
    .controller("TenderDatabaseCtrl", function($scope, Data, $state, TenderDatabaseManager){
        $scope.nowUrl = '#/tenderdatabase';
        $scope.data = {};
        $scope.data.operationList = Data.operationList;

        var num = 10;
        $scope.data.number = parseInt(localStorage.tenderDatabasePageNum);
        var startIndex = localStorage.tenderDatabasePageNum * num - num;

        $scope.data.prevDisable = true;
        $scope.data.nextDisable = false;

        TenderDatabaseManager.getCompanyAssistantListBackground($scope, startIndex);

        $scope.nextPageBtn = function(){
            startIndex = startIndex + num;
            //投标数据库发请求
            TenderDatabaseManager.getCompanyAssistantListBackground($scope, startIndex);
            $scope.data.number = startIndex/num + 1;
            $scope.data.prevDisable = false;
            $scope.number = startIndex;
            localStorage.tenderDatabasePageNum = $scope.data.number;
        };

        $scope.prevPageBtn = function(){
            startIndex = startIndex - num;
            //发送请求
            TenderDatabaseManager.getCompanyAssistantListBackground($scope, startIndex);
            $scope.data.number = startIndex/num + 1;
            if($scope.data.number == 1){
                $scope.data.prevDisable = true;
            }
            $scope.data.nextDisable = false;
            $scope.number = startIndex;
            localStorage.tenderDatabasePageNum = $scope.data.number;
        };

        $scope.btnClicked = function(){
            if($scope.data.number <= 0 || $scope.data.number == undefined){
                $scope.data.number = 1;
            }
            startIndex = $scope.data.number * num - num;
            //发送请求
            TenderDatabaseManager.getCompanyAssistantListBackground($scope, startIndex);
            if($scope.data.number == 1){
                $scope.data.prevDisable = true;
            }
            $scope.number = startIndex;
            localStorage.tenderDatabasePageNum = $scope.data.number;
        };

        $scope.searchBtn = function(){

        };

    })

    //投标数据库详情页面控制器部分
    .controller("TenderDatabaseDetailCtrl", function($scope, TenderDatabaseManager, $stateParams){
        $scope.data = {};

        var num = 10;
        $scope.data.number = parseInt(localStorage.tenderDatabaseDetailPageNum);
        var startIndex = localStorage.tenderDatabaseDetailPageNum * num - num;

        console.log("$stateParams", $stateParams);

        $scope.data.prevDisable = true;
        $scope.data.nextDisable = false;

        $scope.nextPageBtn = function(){
            startIndex = startIndex + num;
            TenderDatabaseManager.getBiddingListByCompanyIdBackground($scope, $stateParams.companyID, startIndex);
            $scope.data.number = startIndex/num + 1;
            $scope.data.prevDisable = false;
            $scope.number = startIndex;
            localStorage.tenderDatabaseDetailPageNum = $scope.data.number;
        };

        $scope.prevPageBtn = function(){
            startIndex = startIndex - num;
            TenderDatabaseManager.getBiddingListByCompanyIdBackground($scope, $stateParams.companyID, startIndex);
            $scope.data.number = startIndex/num + 1;
            if($scope.data.number == 1){
                $scope.data.prevDisable = true;
            }
            $scope.data.nextDisable = false;
            $scope.number = startIndex;
            localStorage.tenderDatabaseDetailPageNum = $scope.data.number;
        };

        $scope.btnClicked = function(){
            if($scope.data.number <= 0 || $scope.data.number == undefined){
                $scope.data.number = 1;
            }
            startIndex = $scope.data.number * num - num;
            // 发送请求
            TenderDatabaseManager.getBiddingListByCompanyIdBackground($scope, $stateParams.companyID, startIndex);
            if($scope.data.number == 1){
                $scope.data.prevDisable = true;
            }
            $scope.number = startIndex;
            localStorage.tenderDatabaseDetailPageNum = $scope.data.number;
        };

        //发送请求
        // .......
        TenderDatabaseManager.getBiddingListByCompanyIdBackground($scope, $stateParams.companyID, startIndex);

    })

    //项目数据库控制器部分
    .controller("ProjectDatabaseCtrl", function($scope, Data, $state, CollegeManager, DateTimeManager){
        $scope.nowUrl = '#/projectdatabase';
        $scope.data = {};
        $scope.data.operationList = Data.operationList;


        $scope.dtstart = new Date();
        $scope.dtend = new Date();
        DateTimeManager.initDate($scope, $scope.dtstart);
        DateTimeManager.initDate($scope, $scope.dtend);

        var startDatetime = new Date();
        var endDatetime = new Date();

        startDatetime.setYear($scope.dtstart.getFullYear());
        startDatetime.setMonth($scope.dtstart.getMonth());
        startDatetime.setDate($scope.dtstart.getDate());
        $scope.data.startDate = startDatetime.Format("yyyy-MM-dd hh:mm:ss").toString();

        endDatetime.setYear($scope.dtend.getFullYear());
        endDatetime.setMonth($scope.dtend.getMonth());
        endDatetime.setDate($scope.dtend.getDate());
        $scope.data.endDate = endDatetime.Format("yyyy-MM-dd hh:mm:ss").toString();

        $scope.dateTime1 = function(){
            //WinbiddingManager.getBiddingListBackground($scope, startIndex, $scope.data.startDate, $scope.data.endDate);
            console.log("我失去焦点了");
        };

        $scope.dateTime2 = function(){
            var startDatetime = new Date();
            var endDatetime = new Date();

            startDatetime.setYear($scope.dtstart.getFullYear());
            startDatetime.setMonth($scope.dtstart.getMonth());
            startDatetime.setDate($scope.dtstart.getDate());

            endDatetime.setYear($scope.dtend.getFullYear());
            endDatetime.setMonth($scope.dtend.getMonth());
            endDatetime.setDate($scope.dtend.getDate());
            //WinbiddingManager.getBiddingListBackground($scope, startIndex, $scope.data.startDate, $scope.data.endDate);
            console.log("我也失去焦点了");
        };

        $scope.nowUrl = '#/projectdatabase';
        $scope.data = {};
        $scope.data.operationList = Data.operationList;
        $scope.data.cityID = '-1';
        $scope.data.number = parseInt(localStorage.projectDatabasePageNum);

        var num = 10;
        var startIndex = localStorage.projectDatabasePageNum * num - num;

        $scope.data.prevDisable = true;
        $scope.data.nextDisable = false;

        $scope.nextPageBtn = function(){
            startIndex = startIndex + num;
            //发请求
            //发送请求语句填写这儿
            $scope.data.number = startIndex/num + 1;
            $scope.data.prevDisable = false;
            $scope.number = startIndex;
            localStorage.projectDatabasePageNum = $scope.data.number;
        };

        $scope.prevPageBtn = function(){
            startIndex = startIndex - num;
            //发送请求
            //
            $scope.data.number = startIndex/num + 1;
            if($scope.data.number == 1){
                $scope.data.prevDisable = true;
            }
            $scope.data.nextDisable = false;
            $scope.number = startIndex;
            localStorage.projectDatabasePageNum = $scope.data.number;
        };

        $scope.btnClicked = function(){
            if($scope.data.number <= 0 || $scope.data.number == undefined){
                $scope.data.number = 1;
            }
            startIndex = $scope.data.number * num - num;
            //发送请求
            //
            if($scope.data.number == 1){
                $scope.data.prevDisable = true;
            }
            $scope.number = startIndex;
            localStorage.projectDatabasePageNum = $scope.data.number;
        };

        $scope.data.projectDatabsase = {
            1001:{
                companyName : "水利工程",
                publishDate : "2017/3/13",
                place : "南京"
            },
            1002:{
                companyName : "水利工程",
                publishDate : "2017/3/14",
                place : "苏州"
            },
            1003:{
                companyName : "水利工程",
                publishDate : "2017/3/14",
                place : "苏州"
            }
        };

        CollegeManager.getCityListBackground($scope);  //获取城市列表
        //筛选城市
        $scope.cityChange = function(cityID){
            $scope.data.cityID = cityID;
            console.log("cityID:", $scope.data.cityID);
            startIndex = 0;
            $scope.number = startIndex;
            num = 10;
            $scope.data.number = 1;
            if($scope.data.number == 1){
                $scope.data.prevDisable = true;
            }
            //发送请求
            //...
        };

        $scope.btnViewDetail = function(){
            $state.go("projectdatabasedetail");
        };

    })

    //项目数据库详情控制器部分
    .controller("ProjectDataBaseDetailCtrl", function($scope){
        $scope.data = {};
        $scope.data.number = 1;
        var startIndex = 0;
        var num = 10;
        $scope.number = startIndex;

        $scope.data.prevDisable = true;
        $scope.data.nextDisable = false;

        $scope.nextPageBtn = function(){
            startIndex = startIndex + num;
            //发送请求
            // .......
            $scope.data.number = startIndex/10 + 1;
            $scope.data.prevDisable = false;
            $scope.number = startIndex;
        };

        $scope.prevPageBtn = function(){
            startIndex = startIndex + num;
            //发送请求
            // ......
            $scope.data.number = startIndex/10 + 1;
            if($scope.data.number == 1){
                $scope.data.prevDisable = true;
            }
            $scope.data.nextDisable = false;
            $scope.number = startIndex;
        };

        $scope.btnClicked = function(){
            if($scope.data.number <= 0 || $scope.data.number ==undefined){
                $scope.data.number = 1;
            }
            startIndex = $scope.data.number * 10 -10;
            //发送请求
            // ......
            if($scope.data.number == 1){
                $scope.data.prevDisable = true;
            }
            $scope.number = startIndex;
        };
    })

    //会员充值活动控制器部分
    .controller("MembersCtrl", function($scope, Data){
        $scope.nowUrl = '#/members';
        $scope.data = {};
        $scope.data.operationList = Data.operationList;
    })

;